package com.zhixi100.testservice.controller;

import com.zhixi100.testservice.entity.PersonCount;
import com.zhixi100.testservice.service.PersonCountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test/v1")
public class PersonCountController {

    @Autowired
    private PersonCountService personCountService;

    @GetMapping("/update/{id}")
    public Object updatePerson(@PathVariable("id") int id) {
        personCountService.updatePerson(id);
        return "success";
    }

    @GetMapping("/get/{id}")
    public Object getPerson(@PathVariable("id") int id) {
        PersonCount personCount = personCountService.getPerson(id);
        return personCount.getNum();
    }

}
